﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;

namespace DevExpress.MailClient.Win.Controls.File_tabs.File_Viewers
{
    public partial class ucWordFileViewer : DevExpress.XtraEditors.XtraUserControl
    {
        public ucWordFileViewer()
        {
            InitializeComponent();
        }

        private string EXTENSION
        { get; set; }
        private string FILE_PATH
        {
            set
            {
                FileInfo docfileInfo = new FileInfo(value);
                //1. copy to a temp place
                //string destinationfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), Path.GetTempFileName() + EXTENSION);
                //docfileInfo.CopyTo(destinationfilePath, true);

                string destinationfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), docfileInfo.Name + EXTENSION);
                if (!new FileInfo(destinationfilePath).Exists)
                {
                    docfileInfo.CopyTo(destinationfilePath, true);
                }

                richEditControl1.LoadDocument(destinationfilePath);
            }
        }
        public ucWordFileViewer(string filePath, string extention)
        {
            InitializeComponent();
            EXTENSION = extention;
            FILE_PATH = filePath;
        }
    }
}
